import React, { Component } from 'react';
import { List, Switch, Button, WingBlank } from 'antd-mobile';
import { createForm } from 'rc-form';

class Setting extends Component {
	goback () {
		this.props.history.push('/user');
	}
	address () {
		this.props.history.push('/address');
	}
	relog () {
		if(localStorage.getItem("username")){
			localStorage.removeItem("username");
			this.props.history.push('/home');
		}
	}
	render() {
		const Item = List.Item;
		const { getFieldProps } = this.props.form;
		return (
			<div className="container">
				<div className="box set-box">
					<div className="header set-header">
						<i className="iconfont icon-left-copy" onClick={this.goback.bind(this)}> 设置</i>
					</div>
					<div className="set-content content">
						<List className="my-list">
							<Item extra="" arrow="horizontal" onClick={this.address.bind(this)}>我的收货地址</Item>
						</List>
						<List className="my-list">
							<Item extra="账户安全级别 中" arrow="horizontal" onClick={() => {}}>账户安全</Item>
						</List>
						<List className="my-list">
							<Item extra="" arrow="horizontal" onClick={() => {}}>内部绑定</Item>
						</List>
						<List className="my-list">
							<Item
							  extra={<Switch {...getFieldProps('1', { initialValue: true, valuePropName: 'checked' })} />}
							>开启省流量模式
							</Item>
							<Item extra="0B" arrow="horizontal" onClick={() => {}}>清除缓存</Item>
						</List>
						<List className="my-list">
							<Item extra="" arrow="horizontal" onClick={() => {}}>购买须知</Item>
							<Item extra="" arrow="horizontal" onClick={() => {}}>关于</Item>
						</List>
						<WingBlank>
							<Button className="relog" onClick={this.relog.bind(this)}
							type="warning">退出登录</Button>
						</WingBlank>
					</div>
				</div>
			</div>
		)
	}
}
		
const SettingWrapper = createForm()(Setting);		
export default SettingWrapper;